<template>
  <div class="page">
    <van-cell-group>
      <van-cell title="收件人" :value="item.childName"/>
      <van-cell title="联系电话" :value="item.mobile"/>
      <van-cell title="地址" :value="item.address"/>
    </van-cell-group>
<!--    <van-panel title="￥12.6" desc="数量:X1    时间:2019/02/22 12:12:12" status="已发货">-->
<!--      <goods :item="goods"></goods>-->
<!--      <div slot="footer">-->
<!--        <van-button size="small" type="danger" @click="doRefund(item.orderID)">我要退款</van-button>-->
<!--      </div>-->
<!--    </van-panel>-->
    <van-panel :title="item.totalAmount"  :desc="item.desc" status="已发货">
      <goods :item="goods"></goods>

      <div slot="footer">
        <van-button size="small" type="danger" @click="doRefund(item.orderID)">我要退款</van-button>
      </div>
    </van-panel>

    <!-- <van-cell-group>
      <van-cell title="快递公司" value="韵达"/>
      <van-cell title="快递单号" value="13344556677"/>
    </van-cell-group> -->
  </div>
</template>

<script>
import Goods from '@/components/Goods2.vue'
import { orderDetail, viewProduct, setRefundStatus } from '@/api'
import mixin from '@/mixin'

export default {
  name: 'order-detail',
  mixins: [mixin],
  components: {
    Goods
  },
  data() {
    return {
      id: '',
      item: {},
      goods: {},
      item2: {
        title: '跟老王学英语',
        price: 0.01,
        oPrice: 200.00,
        desc: '王小二学英语是给小孩子的英语启蒙王小二学英语是给小孩子的英语启蒙王小二学英语是给小孩子的英语启蒙王小二学英语是给小孩子的英语启蒙',
        tag: '限时团购',
        img: 'https://edu-image.nosdn.127.net/07e3b8f9-5721-47bb-a710-ab8cce9cab9e.jpg'
      }
    }
  },
  created() {
    this.getData()
  },
  methods: {
    getData() {
      console.log(this.$router.history.current.query.item);
      this.goods = this.$router.history.current.query.item;
      this.item = this.goods;
      this.item.totalAmount = '￥' + this.item.totalAmount
      this.item.desc = '数量 X' + this.item.numberOfProduct + '      ' + this.item.createTime
      console.log(this.goods)
      // orderDetail(this.id).then(res => {
      //   this.item = res
      //   this.item.totalAmount = '￥' + this.item.totalAmount
      //   this.item.desc = '￥' + this.item.totalAmount
      //   console.log(res);
      //   this.getGoods(res.productID)
      // })
    },
    getGoods(id) {
      viewProduct(id).then(res => {
        console.log(res);
        this.goods = res
      })
    },
    doRefund(orderID) {
      let data = {
        'orderID' : orderID,
        'refundStatus' : 0
      }
      console.log(data)
      setRefundStatus(data).then(res => {
        console.log(res)
        this.$toast('退款成功')
        // this.getGroup()
      })
    },
  }
}
</script>
<style scoped lang="stylus" rel="stylesheet/stylus">
@import '../style/mixin'
.van-panel
  margin $part-width 0
  .van-hairline--top
    text-align right
    &::after
      border-top-width: 0
</style>
